package com.cwz.gulimall.order.vo;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public class OrderConfirmVo {
    @Getter @Setter
    List<MemberAddressVo> address;

    @Getter @Setter
    List<OrderItemVo> items;

    @Getter @Setter
    Integer integration;

    @Getter @Setter
    String orderToken;

    @Getter @Setter
    Map<Long, Boolean> stocks;

//    Integer count;
    public Integer getCount() {
        Integer i = 0;
        if (items != null) {
            for (OrderItemVo item : items) {
                i += item.getCount();
            }
        }
        return i;
    }
//    BigDecimal total;

    public BigDecimal getTotal() {
        BigDecimal total = new BigDecimal("0");
        if (items != null) {
            for (OrderItemVo item : items) {
                 total = total.add(item.getPrice().multiply(new BigDecimal(item.getCount().toString())));
            }
        }
        return total;
    }

//    BigDecimal payPrice;
    public BigDecimal getPayPrice() {
        BigDecimal payPrice = new BigDecimal("0");
        if (items != null) {
            for (OrderItemVo item : items) {
                payPrice = payPrice.add(item.getPrice().multiply(new BigDecimal(item.getCount().toString())));
            }
        }
        return payPrice;
    }

}
